using UnityEngine;
using UnityEngine.UI;

namespace VoxelGame.Utils
{
	public class FarPlaneUtil : MonoBehaviour
	{
		[SerializeField]
		private Camera _camera;

		[SerializeField]
		private Text _farPlaneText;

		[SerializeField]
		private Button _increaseFarPlane;

		[SerializeField]
		private Button _increaseFarPlaneFine;

		[SerializeField]
		private Button _decreaseFarPlane;

		[SerializeField]
		private Button _decreaseFarPlaneFine;

		private void Start()
		{
			_increaseFarPlane.onClick.AddListener(delegate
			{
				ChangeFarPlaneValue(100);
			});
			_increaseFarPlaneFine.onClick.AddListener(delegate
			{
				ChangeFarPlaneValue(10);
			});
			_decreaseFarPlane.onClick.AddListener(delegate
			{
				ChangeFarPlaneValue(-100);
			});
			_decreaseFarPlaneFine.onClick.AddListener(delegate
			{
				ChangeFarPlaneValue(-10);
			});
		}

		private void Update()
		{
			_farPlaneText.text = "Far Plane: " + _camera.farClipPlane.ToString();
		}

		private void ChangeFarPlaneValue(int delta)
		{
			_camera.farClipPlane += delta;
		}
	}
}
